{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Physical parameters of the C12 system\n", "\n", "C12's quantum computer is based on optimized spin qubits. The spin qubit is realized from electrons trapped in a double quantum dot suspended on carbon nanotubes (CNTs) embedded in a silicon nanocircuit and microwave cavity.\n", "\n", "Different physical parameters influence the behavior of our emulator and, consequentially, our gates. Therefore, they can strongly influence the fidelity of the used gate set.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from c12_callisto_clients.api.client import Request\n", "\n", "from c12_callisto_clients.user_configs import UserConfigs\n", "import os\n", "user_auth_token = os.getenv(\"C12_TOKEN\")\n", "configs = UserConfigs.parse_obj({\"token\" : user_auth_token})\n", "# Create the request instance\n", "# Constructor of the Request class also accepts the verbose parameter, which can be use for more detailed output of the methods.\n", "\n", "request = Request(auth_token=user_auth_token, verbose=False)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "B_sym = 0.245 (T)\n", "B_asym = 0.245 (T)\n", "epsilon = 0.0 (V)\n", "half_delta_g = 300e6 (Hz)\n", "omega_b = 14.1e6 (Hz)\n", "omega_t = 19.9e9 (Hz)\n", "omega_s = 12.3e9 (Hz)\n", "lambda_nu_b = 1.5e-05 (Hz)\n", "lambda_nu_t = 5e-08 (Hz)\n", "lambda_nu_s = 2e-07 (Hz)\n", "Q_c = 1e4 (none)\n", "Q_nu_b = 1e2 (none)\n", "Q_nu_t = 1e5 (none)\n", "Q_nu_s = 1e5 (none)\n", "T = 20e-3 (K)\n", "Omega_d = 500e6 (Hz)\n", "power_spect_const = 0.00117 (GHz^2)\n", "time_k = 0.5 (none)\n", "noisy = 1 (none)\n" ] } ], "source": [ "# Getting the physical parameters of the C12 system\n", "physical_params = request.get_params()\n", "\n", "for key, value in physical_params.items():\n", " print(f\"{key} = {value['value']} ({value['unit']})\")" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Changing the physical parameters and passing them when running the emulation is achievable. By doing that, the emulation will be run using the given set of parameters. You can only pass the parameters you want to change. The other ones are going to have the default value.\n", "\n", "It is crucial to notice that changing the physical parameters permanently is impossible! They will have default values until they are changed during the start of the emulation.\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# For more information see notebooks 2 & 3\n", "from c12simulator_clients.user_configs import UserConfigs\n", "from c12simulator_clients.qiskit_back.c12sim_provider import C12SimProvider\n", "\n", "configs = UserConfigs.parse_obj({\"token\" : user_auth_token, \"verbose\": False})\n", "c12_simulator_provider = C12SimProvider(configs)\n", "c12_simulator_backend = c12_simulator_provider.get_backend('c12sim-iswap')\n", "\n", "from qiskit import QuantumCircuit\n", "\n", "circuit = QuantumCircuit(2)\n", "circuit.h(0)\n", "circuit.cx(0, 1)\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "C12 simulation counts: {'00': 5029, '11': 4971}\n" ] } ], "source": [ "# To change the physical parameters we need to create a Python dictionary with the key (parm name) and value (param value) pairs\n", "\n", "new_params = {\n", " \"noisy\" : 0\n", "}\n", "\n", "c12_job = c12_simulator_backend.run(circuit, shots=10000, physical_params=str(new_params))\n", "c12_result = c12_job.result()\n", "c12_counts = c12_result.get_counts()\n", "print(f\"C12 simulation counts: {c12_counts}\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "C12 simulation counts: {'00': 4951, '01': 7, '10': 9, '11': 5033}\n" ] } ], "source": [ "# To change the physical parameters we need to create a python dictionary with the key (parm name) and value (param value) pairs\n", "\n", "new_params = {\n", " \"noisy\" : 1\n", "}\n", "\n", "c12_job = c12_simulator_backend.run(circuit, shots=10000, physical_params=str(new_params))\n", "c12_result = c12_job.result()\n", "c12_counts = c12_result.get_counts()\n", "print(f\"C12 simulation counts: {c12_counts}\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "ename": "C12SimJobError", "evalue": "Unable to retrieve result for job a7fde476-a75c-454f-9837-7bc2cd225c9c. Job finished with an error state. Use error_message() method to get more details.", "output_type": "error", "traceback": [ "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", "\u001B[0;31mC12SimJobError\u001B[0m Traceback (most recent call last)", "Cell \u001B[0;32mIn[8], line 10\u001B[0m\n\u001B[1;32m 8\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m 9\u001B[0m c12_job \u001B[38;5;241m=\u001B[39m c12_simulator_backend\u001B[38;5;241m.\u001B[39mrun(circuit, shots\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m10000\u001B[39m, physical_params\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mstr\u001B[39m(new_params))\n\u001B[0;32m---> 10\u001B[0m c12_result \u001B[38;5;241m=\u001B[39m \u001B[43mc12_job\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mresult\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 11\u001B[0m c12_counts \u001B[38;5;241m=\u001B[39m c12_result\u001B[38;5;241m.\u001B[39mget_counts()\n\u001B[1;32m 12\u001B[0m \u001B[38;5;28mprint\u001B[39m(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mC12 simulation counts: \u001B[39m\u001B[38;5;132;01m{\u001B[39;00mc12_counts\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n", "File \u001B[0;32m~/.miniconda3/lib/python3.11/site-packages/c12_callisto_clients/qiskit_back/c12sim_job.py:228\u001B[0m, in \u001B[0;36mC12SimJob.result\u001B[0;34m(self, timeout, wait)\u001B[0m\n\u001B[1;32m 223\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m C12SimJobError(\n\u001B[1;32m 224\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mUnable to retrieve result for job \u001B[39m\u001B[38;5;132;01m{\u001B[39;00m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_job_id\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m. Job was cancelled\u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m 225\u001B[0m )\n\u001B[1;32m 227\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_status \u001B[38;5;129;01mis\u001B[39;00m JobStatus\u001B[38;5;241m.\u001B[39mERROR:\n\u001B[0;32m--> 228\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m C12SimJobError(\n\u001B[1;32m 229\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mUnable to retrieve result for job \u001B[39m\u001B[38;5;132;01m{\u001B[39;00m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_job_id\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m. \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m 230\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mJob finished with an error state. \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m 231\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mUse error_message() method to get more details.\u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m 232\u001B[0m )\n\u001B[1;32m 233\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mrefresh()\n\u001B[1;32m 234\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_result \u001B[38;5;241m=\u001B[39m Result(\n\u001B[1;32m 235\u001B[0m backend_name\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_backend,\n\u001B[1;32m 236\u001B[0m backend_version\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_backend\u001B[38;5;241m.\u001B[39mversion,\n\u001B[0;32m (...)\u001B[0m\n\u001B[1;32m 241\u001B[0m status\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_status,\n\u001B[1;32m 242\u001B[0m )\n", "\u001B[0;31mC12SimJobError\u001B[0m: Unable to retrieve result for job a7fde476-a75c-454f-9837-7bc2cd225c9c. Job finished with an error state. Use error_message() method to get more details." ] } ], "source": [ "# Also, it is possible that some given parameters are outside the ranges that are making them physically impossible\n", "from c12simulator_clients.qiskit_back.exceptions import C12SimJobError\n", "new_params = {\n", " \"Omega_d\" : 600e10\n", "}\n", "\n", "c12_job = c12_simulator_backend.run(circuit, shots=10000, physical_params=str(new_params))\n", "try:\n", " c12_result = c12_job.result()\n", " c12_counts = c12_result.get_counts()\n", " print(f\"C12 simulation counts: {c12_counts}\")\n", "except C12SimJobError:\n", " print(c12_job.error_message()) # Error number 1010 is because the values for the parameters are outside the range\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Error: 1007 \n" ] } ], "source": [ "print(c12_job.error_message())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "C12", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 4 }